/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Entity;

import java.io.Serializable;
import java.math.BigInteger;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.JoinColumns;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author WinKiQue58
 */
@Entity
@Table(name = "MEMBER_STATUS")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "MemberStatus.findAll", query = "SELECT m FROM MemberStatus m"),
    @NamedQuery(name = "MemberStatus.findByIdMemberStatus", query = "SELECT m FROM MemberStatus m WHERE m.memberStatusPK.idMemberStatus = :idMemberStatus"),
    @NamedQuery(name = "MemberStatus.findByIdPersonalInfo", query = "SELECT m FROM MemberStatus m WHERE m.memberStatusPK.idPersonalInfo = :idPersonalInfo"),
    @NamedQuery(name = "MemberStatus.findByIdBranchenterprise", query = "SELECT m FROM MemberStatus m WHERE m.memberStatusPK.idBranchenterprise = :idBranchenterprise"),
    @NamedQuery(name = "MemberStatus.findByIdEnterprise", query = "SELECT m FROM MemberStatus m WHERE m.memberStatusPK.idEnterprise = :idEnterprise"),
    @NamedQuery(name = "MemberStatus.findByName", query = "SELECT m FROM MemberStatus m WHERE m.name = :name"),
    @NamedQuery(name = "MemberStatus.findByDescription", query = "SELECT m FROM MemberStatus m WHERE m.description = :description"),
    @NamedQuery(name = "MemberStatus.findByInitdate", query = "SELECT m FROM MemberStatus m WHERE m.initdate = :initdate"),
    @NamedQuery(name = "MemberStatus.findByEnddate", query = "SELECT m FROM MemberStatus m WHERE m.enddate = :enddate")})
public class MemberStatus implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected MemberStatusPK memberStatusPK;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 180)
    @Column(name = "NAME")
    private String name;
    @Size(max = 45)
    @Column(name = "DESCRIPTION")
    private String description;
    @Basic(optional = false)
    @NotNull
    @Column(name = "INITDATE")
    @Temporal(TemporalType.TIMESTAMP)
    private Date initdate;
    @Column(name = "ENDDATE")
    @Temporal(TemporalType.TIMESTAMP)
    private Date enddate;
    @JoinColumns({
        @JoinColumn(name = "ID_PERSONAL_INFO", referencedColumnName = "ID_PERSONAL_INFO", insertable = false, updatable = false),
        @JoinColumn(name = "ID_BRANCHENTERPRISE", referencedColumnName = "ID_BRANCHENTERPRISE", insertable = false, updatable = false),
        @JoinColumn(name = "ID_ENTERPRISE", referencedColumnName = "ID_ENTERPRISE", insertable = false, updatable = false)})
    @ManyToOne(optional = false, fetch = FetchType.LAZY)
    private PersonalInfo personalInfo;

    public MemberStatus() {
    }

    public MemberStatus(MemberStatusPK memberStatusPK) {
        this.memberStatusPK = memberStatusPK;
    }

    public MemberStatus(MemberStatusPK memberStatusPK, String name, Date initdate) {
        this.memberStatusPK = memberStatusPK;
        this.name = name;
        this.initdate = initdate;
    }

    public MemberStatus(BigInteger idMemberStatus, BigInteger idPersonalInfo, BigInteger idBranchenterprise, BigInteger idEnterprise) {
        this.memberStatusPK = new MemberStatusPK(idMemberStatus, idPersonalInfo, idBranchenterprise, idEnterprise);
    }

    public MemberStatusPK getMemberStatusPK() {
        return memberStatusPK;
    }

    public void setMemberStatusPK(MemberStatusPK memberStatusPK) {
        this.memberStatusPK = memberStatusPK;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public Date getInitdate() {
        return initdate;
    }

    public void setInitdate(Date initdate) {
        this.initdate = initdate;
    }

    public Date getEnddate() {
        return enddate;
    }

    public void setEnddate(Date enddate) {
        this.enddate = enddate;
    }

    public PersonalInfo getPersonalInfo() {
        return personalInfo;
    }

    public void setPersonalInfo(PersonalInfo personalInfo) {
        this.personalInfo = personalInfo;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (memberStatusPK != null ? memberStatusPK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof MemberStatus)) {
            return false;
        }
        MemberStatus other = (MemberStatus) object;
        if ((this.memberStatusPK == null && other.memberStatusPK != null) || (this.memberStatusPK != null && !this.memberStatusPK.equals(other.memberStatusPK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "Entity.MemberStatus[ memberStatusPK=" + memberStatusPK + " ]";
    }
    
}
